package com.aviation.sell_ticket.tool;

import com.aviation.sell_ticket.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RabbitMQUtil {

    @Resource
    RabbitTemplate rabbitTemplate;

    /**
     * 订单号送入队列
     * @param msg 订单号
     */
    public void orderDelay(String msg) {
        Integer delayed = 6000*10*30;
        rabbitTemplate.convertAndSend(RabbitMQConfig.ORDER_EXCHANGE
                , RabbitMQConfig.ORDER_ROUTING_KEY, msg, message -> {
                    //设置发送消息的延迟时间
                    message.getMessageProperties().setDelay(delayed);
                    return message;
                });
    }


}
